/**
 * 开票信息 - 编辑页面
 * @author miaoyl
 * @date 2018/01/09
 */
define(function () {

    var self,
        app = win.app,
        doc = document,
        vueData = {
            isAdd: false,
            form: {
                GWAK001: '',
                GWAKL004: '',
                GWAK004: '',
                GWAK003: '',
                GWAK013: '',
                GWAK014: '',
                GWAK007: '',
                GWAK028: ''
            },
            rules: {

            }
        },
        callObj,
        cb
    ;

    var Gwei025Edit = app.Module.extend({
        init: function () {
            self = this;
            self._super({
                _tag: 'gwei025_edit_gwak',
            }, win);
        },

        editData: function () {
            app.ajax({
                xurl: 'crm/gwei025/editGwak',
                xdata: vueData.form,
                loading: true,
                okmsg: '开票信息修改成功',
                cb: function (result) {
                    if (result.ok) {
                        layer.close(layer.index);
                        cb(vueData.form);
                    }
                }
            });
        },

        _call: function (obj) {
            cb = obj.cb;
            app.ajax({
                xurl: 'crm/gwei025/selectGwakByKey',
                xdata: {GWAK001: obj.GWAK001},
                cb: function (result) {
                    if (result.ok) {
                        app.extendUpLow({
                            target: vueData.form,
                            res: result.data.data,
                            reset: true
                        });
                    }
                }
            });
        },
        _ready: function () {
            var vue = new Vue({
                el: '#gwei025_edit_gwak',
                data: vueData,
                methods: {
                    cancel: function () {
                        layer.close(layer.index);
                    },
                    saveData: function () {
                        this.$refs['form'].validate(function (valid) {
                            if (valid) {
                                self.editData();
                            }
                        });
                    }
                },
                watch: {},
                created: function () {
                    self._setEleIsReady('gwei025_edit_gwak');
                }
            });
        },

        _lazy: function () {
            this._super();
        }
    });

    return new Gwei025Edit();

});